const express = require("express");
const app = express();
var md5 = require('md5');

//引入数据库连接文件
require("./db")

//引入外部路由
const addAdminRoute = require("./routes/addAdmin");
const adminListRoute = require("./routes/adminList");
const deleteAdminRoute = require("./routes/deleteAdmin")
const loginRoute = require("./routes/login")
const isLogin=require('./routes/isLogin')
const logout = require("./routes/logout")
const addAdv = require("./routes/addAdv")
const advList = require("./routes/advList")

//处理post请求体的中间件,会在req上添加一个body属性,值是请求体参数
app.use(express.json())
app.use(express.urlencoded()) 

//使用路由
app.use(addAdminRoute)
app.use(adminListRoute)
app.use(deleteAdminRoute)
app.use(loginRoute)
app.use(isLogin)
app.use(logout)
app.use(addAdv)
app.use(advList)

app.listen("8000", () => {
  console.log("服务器启动成功 http://127.0.0.1:8000");
})